﻿<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <!-- jsp文件头和头部 -->
    <%@ include file="../admin/top.jsp" %>
    <link rel="stylesheet" href="static/css/zcss/soso.css"/>
</head>
<body>

<div class="container-fluid" id="main-container">


    <div id="page-content" class="clearfix">

        <div class="row-fluid">

            <div class="row-fluid">
                <!-- 检索  -->
                <form action="user/list.do" method="post" name="userForm" id="userForm" class="zform">
                    <table class="zform-tab">
                        <tr>
                            <td>
                                 <span class="input-icon sosodiv">
                                    <input autocomplete="off" class="nav-search-input" type="text"
                                           name="userNameKey" value="${userNameKey }" placeholder="这里输入用户名或用户ID"/>
                                <i id="nav-search-icon" class="icon-search"></i>
                                 </span>

                            </td>
                            <td style="vertical-align:top;">
                                <select class="chzn-select" name="roleIdKey" id="roleIdKey" data-placeholder="请选择职位"
                                        style="vertical-align:top;width: 120px;">
                                    <option value="">全部</option>
                                    <c:forEach items="${roleList}" var="role">
                                        <option value="${role.ROLE_ID }"
                                                <c:if test="${roleIdKey == role.ROLE_ID}">selected</c:if>>${role.ROLE_NAME }
                                        </option>
                                    </c:forEach>
                                </select>
                            </td>
                            <td class="tdbtn">
                                <button class="btn zbtn" onclick="search();" title="检索"
                                        style="line-height: 27px;width: 80%;background: #438EB9!important;border: none;border-radius: 8px!important;color: #fff;margin-top: 3px;">
                                    搜索
                                </button>
                            </td>
                        </tr>
                    </table>
                    <!-- 检索  -->
                </form>

                <table id="table_report" class="table table-striped table-bordered table-hover">

                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>用户名</th>
                        <th>姓名</th>
                        <th>余额</th>
                        <th>平台</th>
                        <th>职位</th>
                        <th><i class="icon-envelope"></i>邮箱</th>
                        <th><i class="icon-time hidden-phone"></i>最近登录</th>
                        <th>上次登录IP</th>
                        <th class="center">操作</th>
                    </tr>
                    </thead>

                    <tbody>

                    <!-- 开始循环 -->
                    <c:choose>
                        <c:when test="${not empty userList}">
                            <c:if test="${QX.cha == 1 }">
                                <c:forEach items="${userList}" var="user" varStatus="vs">

                                    <tr>
                                        <td class='center' style="width: 30px;">${vs.index+1}</td>
                                        <td><a>${user.USERNAME }</a></td>
                                        <td>${user.NAME }</td>
                                        <td>${user.balance }</td>
                                        <td>${user.appId }</td>
                                        <td>${user.role.ROLE_NAME }</td>
                                        <c:if test="${QX.FX_QX == 1 }">
                                            <td><a title="发送电子邮件" style="text-decoration:none;cursor:pointer;"
                                                   onclick="sendEmail('${user.email }');">${user.email }&nbsp;<i
                                                    class="icon-envelope"></i></a></td>
                                        </c:if>
                                        <c:if test="${QX.FX_QX != 1 }">
                                            <td><a title="您无权发送电子邮件"
                                                   style="text-decoration:none;cursor:pointer;">${user.email }&nbsp;<i
                                                    class="icon-envelope"></i></a></td>
                                        </c:if>
                                        <td>${user.LAST_LOGIN}</td>
                                        <td>${user.IP}</td>
                                        <td style="width: 60px;">
                                            <div class='hidden-phone visible-desktop btn-group'>

                                                <c:if test="${QX.edit == 1 }">
                                                    <c:if test="${user.USERNAME != 'admin'}"><a
                                                            class='btn btn-mini btn-info' title="编辑"
                                                            onclick="editUser('${user.USER_ID }');"><i
                                                            class='icon-edit'></i></a></c:if>
                                                    <c:if test="${user.USERNAME == 'admin'}"><a
                                                            class='btn btn-mini btn-info' title="您不能编辑"><i
                                                            class='icon-edit'></i></a></c:if>
                                                </c:if>
                                                <c:choose>
                                                    <c:when test="${user.USERNAME=='admin'}">
                                                        <a class='btn btn-mini btn-danger' title="不能删除"><i
                                                                class='icon-trash'></i></a>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <c:if test="${QX.del == 1 }">
                                                            <a class='btn btn-mini btn-danger' title="删除"
                                                               onclick="delUser('${user.USER_ID }','${user.USERNAME }');"><i
                                                                    class='icon-trash'></i></a>
                                                        </c:if>
                                                    </c:otherwise>
                                                </c:choose>
                                            </div>
                                        </td>
                                    </tr>

                                </c:forEach>
                            </c:if>

                            <c:if test="${QX.cha == 0 }">
                                <tr>
                                    <td colspan="10" class="center">您无权查看</td>
                                </tr>
                            </c:if>
                        </c:when>
                        <c:otherwise>
                            <tr class="main_info">
                                <td colspan="10" class="center">没有相关数据</td>
                            </tr>
                        </c:otherwise>
                    </c:choose>


                    </tbody>
                </table>

                <div class="page-header position-relative" style="float: left;width: 100%;">
                    <table style="width:100%;">
                        <tr>
                            <td style="vertical-align:top;">
                                <c:if test="${QX.add == 1 }">
                                    <a class="btn btn-small btn-success" onclick="add();">新增</a>
                                </c:if>
                                <c:if test="${QX.del == 1 }">
                                    <a title="批量删除" class="btn btn-small btn-danger"
                                       onclick="makeAll('确定要删除选中的数据吗?');"><i class='icon-trash'></i></a>
                                </c:if>
                            </td>
                            <td style="vertical-align:top;">
                                <div class="pagination"
                                     style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div>
                            </td>
                        </tr>
                    </table>
                </div>


            </div>
            <!-- PAGE CONTENT ENDS HERE -->
        </div><!--/row-->

    </div><!--/#page-content-->
</div><!--/.fluid-container#main-container-->

<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
    <i class="icon-double-angle-up icon-only"></i>
</a>

<!-- 引入 -->
<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/ace-elements.min.js"></script>
<script src="static/js/ace.min.js"></script>

<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
<!-- 引入 -->


<script type="text/javascript" src="static/js/jquery.tips.js"></script><!--提示框-->
<script type="text/javascript">

    $(top.hangge());

    //检索
    function search() {
        top.jzts();
        $("#userForm").submit();
    }

    //新增
    function add() {
        top.jzts();
        var diag = new top.Dialog();
        diag.Drag = true;
        diag.Title = "新增";
        diag.URL = '<%=basePath%>user/goAddU.do';
        diag.Width = 225;
        diag.Height = 515;
        diag.CancelEvent = function () { //关闭事件
            if (diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none') {
                if ('${page.currentPage}' == '0') {
                    top.jzts();
                    setTimeout("self.location=self.location", 100);
                } else {
                    nextPage(${page.currentPage});
                }
            }
            diag.close();
        };
        diag.show();
    }

    //修改
    function editUser(user_id) {
        top.jzts();
        var diag = new top.Dialog();
        diag.Drag = true;
        diag.Title = "资料";
        diag.URL = '<%=basePath%>user/goEditU.do?USER_ID=' + user_id;
        diag.Width = 225;
        diag.Height = 515;
        diag.CancelEvent = function () { //关闭事件
            if (diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none') {
                nextPage(${page.currentPage});
            }
            diag.close();
        };
        diag.show();
    }

    //删除
    function delUser(userId, msg) {
        bootbox.confirm("确定要删除[" + msg + "]吗?", function (result) {
            if (result) {
                top.jzts();
                var url = "<%=basePath%>user/deleteU.do?USER_ID=" + userId + "&tm=" + new Date().getTime();
                $.get(url, function (data) {
                    nextPage(${page.currentPage});
                });
            }
        });
    }

</script>

<script type="text/javascript">

    $(function () {

        //日期框
        $('.date-picker').datepicker();

        //下拉框
        $(".chzn-select").chosen();
        $(".chzn-select-deselect").chosen({allow_single_deselect: true});

        //复选框
        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });

    });

</script>

</body>
</html>